<template>
  <div>
    <el-row style="line-height: 35px; ">
      <el-col :span="15">
        <el-button icon="el-icon-back"
                   size="small"
                   type="text"
                   @click="$router.go(-1)">返回</el-button>
        <span> | 子任务历史 </span>
      </el-col>
    </el-row>
    <el-table :data='historyList'
              :height="tableHeight"
              stripe
              use-virtual>
      <el-table-column label="任务名称" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-html="scope.row.taskItemName"/>
        </template>
      </el-table-column>
      <el-table-column label="类型" show-overflow-tooltip>
        <template slot-scope="scope">
          <span v-text="CONST.TASK_ITEM_STATUS_VO.find(item => item.value === scope.row.type).label"></span>
        </template>
      </el-table-column>
      <el-table-column label="创建人" prop="createdBy">
        <template slot-scope="scope">
          <span v-html="$store.state.userList.find(item => item.userName === scope.row.createdBy).name"></span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" prop="updatedTime"/>
      <el-table-column label="状态" prop="status">
        <template slot-scope="scope">
          <span>{{ CONST.TASK_ITEM_STATUS.find(item => item.value === scope.row.status).key }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <span><el-link @click.prevent="showHistoryDetail(scope.row)">详情</el-link></span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    name: "TaskItemHistory",
    data() {
      return {
        tableHeight: CONST.WORKSPACE_HEIGHT - 50,
        historyList: [],
        taskName: '',
      }
    },
    methods: {
      showHistoryDetail(taskItem) {
        this.axios.get('/pmph/action/knowledgeUnit/selectTaskItemDetail',
          {params: {
              taskId: taskItem.knowledgeUnitParseKnowledgeTaskId,
              taskItemId: taskItem.id,
            }})
          .then((response) => {
            this.$store.commit('setEditingKnowledge', response.data.knowledge)
            this.$store.commit('setKnowledgeList', [response.data.knowledge])
            this.$router.push('/material/taskItemDetail')
          })
      },
      selectItemHistory() {
        this.axios.get('/pmph/action/knowledgeUnit/selectItemHistory',
        {params: {
            taskId: this.$store.state.knowledgeUnitParseKnowledgeTaskId,
          }})
          .then((response) => this.historyList = response.data)
      },
    },
    created() {
      this.selectItemHistory()
    }
  }
</script>

<style scoped>

</style>
